package org.zfes.snowier.cloud.zbss.layer.tc.biz.controller;

import java.util.Map;
import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.zfes.snowier.core.data.DataSet;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.cloud.zbss.layer.tc.biz.model.SalaryPercentage;
import org.zfes.snowier.cloud.zbss.layer.tc.biz.service.ISalaryPercentageService;
@Controller 
@RequestMapping("/tcms/salaryPercentage")
public class SalaryPercentageController extends BaseController {

	private String viewPathPrefix="/tcms";
	
	@Autowired
	private ISalaryPercentageService salaryPercentageService;
	
	@RequestMapping(value={"/",""}, method = RequestMethod.GET,produces = MediaType.TEXT_HTML_VALUE)
    public Object index(){
		return forward(viewPathPrefix,"salaryPercentage.html");
    }
	
	//@RequiresPermissions(value="salaryPercentage:loadSalaryPercentageList",desc="授薪人员提成列表")
    @RequestMapping(value="/loadSalaryPercentageDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadSalaryPercentageDataSet(@RequestParam Map<String,Object> params){
	    DataSet dataSet=  salaryPercentageService.loadSalaryPercentageDataSet(params);
	    return dataSet;
    }
	
	//@RequiresPermissions(value="salaryPercentage:addSalaryPercentage",desc="授薪人员提成添加")
    @RequestMapping(value="/addSalaryPercentage", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public  @ResponseBody Object addSalaryPercentage(SalaryPercentage salaryPercentage){
		salaryPercentageService.createSalaryPercentage(salaryPercentage);
    	return ajaxDoneSuccess("数据操作成功 ");
    }
	
	//@RequiresPermissions(value="salaryPercentage:loadSalaryPercentage",desc="授薪人员提成加载")
    @RequestMapping(value="/loadSalaryPercentage", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadSalaryPercentage(Long id){
		Optional<SalaryPercentage> ops = salaryPercentageService.loadSalaryPercentageById(id);
		return ajaxQuery("salaryPercentage",ops);
    }
	
	//@RequiresPermissions(value="salaryPercentage:updateSalaryPercentage",desc="授薪人员提成更新")
    @RequestMapping(value="/updateSalaryPercentage", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object updateSalaryPercentage(SalaryPercentage salaryPercentage){
		salaryPercentageService.updateSalaryPercentage(salaryPercentage);
		return ajaxDoneSuccess("数据操作成功 ");
    }
	
	//@RequiresPermissions(value="salaryPercentage:deletSalaryPercentage",desc="授薪人员提成删除")
    @RequestMapping(value="/deletSalaryPercentage", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object deletSalaryPercentage(Long id){
		salaryPercentageService.deletSalaryPercentage(id);
		return ajaxDoneSuccess("数据操作成功 ");
    }

}